<?php

class Khoahoc_model extends CI_Model {

    private $tbl_khoahoc= 'khoahoc';
    //khai bao bien dung rieng trong model su dung tÆ°Æ¡ng tac vÆ¡i table khoahoc
    //khoahoc= $tbl_khoahoc


    function __construct(){
        parent::__construct();
    }

    function list_all(){
        $this->db->order_by('id','DESC');
        return $this->db->get($tbl_khoahoc);
    }

    function count_all(){
        return $this->db->count_all($this->tbl_khoahoc);
    }

    function get_paged_list($limit = 10, $offset = 0){
        $this->db->order_by('id','asc');
        return $this->db->get($this->tbl_khoahoc, $limit, $offset);
    }

    function get_by_id($id){
        $this->db->where('id', $id);
        return $this->db->get($this->tbl_khoahoc);
    }

    function save($khoahoc){
        $this->db->insert($this->tbl_khoahoc, $khoahoc);
        return $this->db->insert_id();
    }

    function update($id, $khoahoc){
        $this->db->where('id', $id);
        $this->db->update($this->tbl_khoahoc, $khoahoc);
    }

    function delete($id){
        $this->db->where('id', $id);
        $this->db->delete($this->tbl_khoahoc);
    }
}
?>